home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / ispell40.lha / ispell-4.0 / hash.h < prev    next >
C/C++ Source or Header  |  1993-05-31  |  3KB  |  130 lines

  1. /* Copyright (C) 1990, 1993 Free Software Foundation, Inc.
  2.  
  3.    This file is part of GNU ISPELL.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.    GNU General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. typedef unsigned short str_index;
  20. typedef unsigned short hash_index;
  21. typedef unsigned char comp_char;
  22.  
  23. struct hash_table_entry
  24.   {
  25.     hash_index next;
  26.     union
  27.       {
  28.     struct short_word
  29.       {
  30.         comp_char data[6];
  31.       } s;
  32.     struct long_word
  33.       {
  34.         unsigned char short_flag;
  35.         unsigned char len;
  36.         comp_char data[2];
  37.         str_index sindex;
  38.       } l;
  39.       } u;
  40.   };
  41.  
  42.  
  43. /* EMPTY or END close collision chains */
  44. #define HASH_EMPTY        ((hash_index)0xffff)
  45. #define HASH_END          ((hash_index)0xfffe)
  46. #define HASH_SPECIAL      ((hash_index)0xfff0)
  47.  
  48.  
  49. struct hash_header
  50.   {
  51.     unsigned long magic;
  52.     unsigned long version;
  53.     unsigned long lexletters;
  54.     unsigned long lexsize;
  55.     unsigned long hashsize;
  56.     unsigned long stblsize;
  57.     unsigned char used[32];    /* 256 bits for which characters used */
  58.   };
  59.  
  60. /* 'HASH'compressed using an early table (!) */
  61. #define HMAGIC ('I' + ('S'<<8) + ((long)'P'<<16) + ((long)'L'<<24))
  62.  
  63. #define VERSION 3
  64.  
  65. #define V_FLAG      1
  66. #define N_FLAG      2
  67. #define X_FLAG      4
  68. #define H_FLAG      8
  69. #define Y_FLAG 0x0010
  70. #define G_FLAG 0x0020
  71. #define J_FLAG 0x0040
  72. #define D_FLAG 0x0080
  73. #define T_FLAG 0x0100
  74. #define R_FLAG 0x0200
  75. #define Z_FLAG 0x0400
  76. #define S_FLAG 0x0800
  77. #define P_FLAG 0x1000
  78. #define M_FLAG 0x2000
  79.  
  80. #define flag_char(f) ("vnxhygjdtrzspm??"[f])
  81.  
  82. extern hash_index hashsize;
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89. #define VOWEL 1
  90. #define SXZH 2
  91. #define Y 4
  92. #define LEXLETTER 8
  93.  
  94. #define isvowel(c) ((ctbl+1)[(unsigned char)(c)] & VOWEL)
  95. #define issxzh(c)  ((ctbl+1)[(unsigned char)(c)] & SXZH)
  96. #define issxzhy(c) ((ctbl+1)[(unsigned char)(c)] & (SXZH | Y))
  97. #define islexletter(c) ((ctbl+1)[(unsigned char)(c)] & LEXLETTER)
  98.  
  99. extern unsigned char ctbl[];
  100.  
  101. #ifdef __STDC__
  102.  
  103. str_index copy_out_string (comp_char *, int);
  104. int hash_emptyp (hash_index);
  105. hash_index hash_find_end (hash_index);
  106. void hash_store (hash_index, struct hash_table_entry *);
  107. void hash_retrieve (hash_index, struct hash_table_entry *);
  108. void hash_set_next (hash_index, hash_index);
  109. hash_index hash_lookup (comp_char *, int);
  110. int hash_init (char *);
  111. unsigned short get_flags (hash_index);
  112. char *htetostr (struct hash_table_entry *, hash_index);
  113. unsigned int hash (char *);
  114.  
  115. #else
  116.  
  117. extern str_index copy_out_string ();
  118. extern int hash_emptyp ();
  119. extern hash_index hash_find_end ();
  120. extern void hash_store ();
  121. extern void hash_retrieve ();
  122. extern void hash_set_next ();
  123. extern hash_index hash_lookup ();
  124. extern int hash_init ();
  125. extern unsigned short get_flags ();
  126. extern char *htetostr ();
  127. extern unsigned int hash ();
  128.  
  129. #endif
  130.